<template>
  <div class="system-user-container layout-padding">
    <el-card class="layout-padding-auto" shadow="hover">
      <el-form :model="state.form" label-width="auto">

        <el-form-item label="支付方式">
          <el-checkbox-group v-model="state.form.pay_type">
            <el-checkbox v-for="item in state.payType" :key="item.id" :label="item.id" :value="item.id">
              {{ item.title }}
            </el-checkbox>


          </el-checkbox-group>
        </el-form-item>

        <el-form-item>
          <el-button v-loading="state.submitLoading" type="primary" @click="onSubmit">保存</el-button>
          <!--          <el-button></el-button>-->
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>

<script lang="ts" setup>
import {onMounted, reactive} from "vue";
import {useBaseApi} from "/@/api/base";
import {ElMessage} from "element-plus";


const state = reactive({
  form: {
    pay_type: []
  },
  payType: [],
  submitLoading: false
})
onMounted(() => {
  useBaseApi().list('payConfig', {}).then(res => {
    state.payType = res.data
  })
})
const onSubmit = () => {
  state.submitLoading = true
  useBaseApi().add('payConfig', state.form).then(res => {
    ElMessage.success('保存成功')
    state.submitLoading = false
  }).catch(_ => {
    state.submitLoading = false
  })
}
</script>

<style lang="scss" scoped>

</style>
